
package robotinterface;

import javax.swing.*;

/**
 *
 * @author Nate Hemmes
 */
public class BuildSlider extends JPanel{

    public BuildSlider(String label, int min, int max){
        int init = (max - min)/2;
        SpringLayout jointLayout = new SpringLayout();
        setLayout(jointLayout);
        setBorder(BorderFactory.createEtchedBorder());

        JLabel jointLabel = new JLabel(label);
        JSlider jointSlider = new JSlider(JSlider.HORIZONTAL, min, max, init);

        add(jointLabel);
        jointLayout.putConstraint(SpringLayout.NORTH, jointLabel, 0, SpringLayout.NORTH, this);
        jointLayout.putConstraint(SpringLayout.WEST, jointLabel, 40, SpringLayout.WEST, this);
        jointLayout.putConstraint(SpringLayout.SOUTH, jointLabel, 0, SpringLayout.SOUTH, this);
        jointLayout.putConstraint(SpringLayout.EAST, jointLabel, -340, SpringLayout.EAST, this);

        add(jointSlider);
        jointLayout.putConstraint(SpringLayout.NORTH, jointSlider, 0, SpringLayout.NORTH, this);
        jointLayout.putConstraint(SpringLayout.WEST, jointSlider, 10, SpringLayout.EAST, jointLabel);
        jointLayout.putConstraint(SpringLayout.SOUTH, jointSlider, 0, SpringLayout.SOUTH, this);
        jointLayout.putConstraint(SpringLayout.EAST, jointSlider, -10, SpringLayout.EAST, this);
    }
}
